<script setup lang="ts">
import type { Relationship } from '@/types/user'
import { useAppConfig, useAppStatus, useProfile } from '@/stores'
import {
  useNav,
} from '@/utils'
import { silenceLogin } from '@/utils/login'
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
import { isEmpty, isNil } from 'lodash-es'
import { useConsole, useModal } from './utils'

const appStatus = useAppStatus()
const profile = useProfile()

onLaunch((options) => {
  useConsole?.log('app:onLaunch', options)
  appStatus.launchComplate = true
  if (options?.path !== 'add/index' && options?.path !== 'add/pdf') {
  // // 静默登录
    if (!profile.checkCache()) {
    // silenceLogin()
      useNav('/me/login')
    }
    // 仅将缓存写入内存
    else {
      profile.init()
    }
  }
})

onShow(async (query) => {
  // useConsole?.log('app:onShow', query?.query)

  // // return
  // await useAppConfig().fetchData()
})

onHide(() => { })
</script>

<style lang="less">
/* #ifdef H5 */
:root {
  --uno: 'font-system text-16px';

  --sat: env(safe-area-inset-top);
  --sar: env(safe-area-inset-right);
  --sab: env(safe-area-inset-bottom);
  --sal: env(safe-area-inset-left);
}

uni-page,
uni-page-body {
  --uno: 'bg-theme-pagebg';
}

/* #endif */

/* #ifdef MP */
page {
  --uno: 'bg-theme-pagebg';
}

button {
  --uno: 'b-none';
}

/* #endif */

view,
textarea {
  --uno: 'box-border';
}

view {
  --uno: 'lh-none box-border';
}

input,
textarea {
  --uno: 'bg-transparent w-full p-0';
}

.uni-page-refresh {
  .uni-page-refresh-inner {
    .uni-page-refresh__icon {
      fill: #f7920d !important;
    }

    .uni-page-refresh__spinner {
      .uni-page-refresh__path {
        stroke: #f7920d !important;
      }
    }
  }
}

.uni-modal {
  border-radius: 10rpx;
}
</style>
